package chen.bupt.help.kdtree;

/**
 * Created by chenlingpeng on 2014/12/8.
 */
public class Rect {
    public Rect(int k) {
        min = new Point(k);
        max = new Point(k);
    }

    public Rect(Rect rect) {
        min = new Point(rect.min);
        max = new Point(rect.max);
    }

    public Point min;
    public Point max;

    public double[] closest(double[] point) {
        Point p = new Point(point.length);
        for(int i=0;i<point.length;i++){
            if(point[i]<=min.vec[i]){
                p.vec[i] = min.vec[i];
            } else if(point[i]>=max.vec[i]){
                p.vec[i] = max.vec[i];
            }else{
                p.vec[i] = point[i];
            }
        }
        return p.vec;
    }
}
